﻿using System;
using Microsoft.Xna.Framework.Graphics;

namespace Terraria.Graphics.Shaders
{
	// Token: 0x02000392 RID: 914
	public class ShaderData
	{
		// Token: 0x1700022C RID: 556
		// (get) Token: 0x06002053 RID: 8275 RVA: 0x00016C29 File Offset: 0x00014E29
		public Effect Shader
		{
			get
			{
				if (this._shader != null)
				{
					return this._shader.Value;
				}
				return null;
			}
		}

		// Token: 0x06002054 RID: 8276 RVA: 0x00016C40 File Offset: 0x00014E40
		public ShaderData(Ref<Effect> shader, string passName)
		{
			this._passName = passName;
			this._shader = shader;
		}

		// Token: 0x06002055 RID: 8277 RVA: 0x00016C56 File Offset: 0x00014E56
		public void SwapProgram(string passName)
		{
			this._passName = passName;
			if (passName != null)
			{
				this._effectPass = this.Shader.CurrentTechnique.Passes[passName];
			}
		}

		// Token: 0x06002056 RID: 8278 RVA: 0x0045C094 File Offset: 0x0045A294
		protected virtual void Apply()
		{
			if (this._shader != null && this._lastEffect != this._shader.Value && this.Shader != null && this._passName != null)
			{
				this._effectPass = this.Shader.CurrentTechnique.Passes[this._passName];
			}
			this._effectPass.Apply();
		}

		// Token: 0x04003CF7 RID: 15607
		protected Ref<Effect> _shader;

		// Token: 0x04003CF8 RID: 15608
		protected string _passName;

		// Token: 0x04003CF9 RID: 15609
		private EffectPass _effectPass;

		// Token: 0x04003CFA RID: 15610
		private Effect _lastEffect;
	}
}
